Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed statefulset PVC's capacity in kubectl description. #47573

Merged
merged 1 commit into from
Jun 21, 2017

Conversation

k82cn
Copy link
Member

@k82cn k82cn commented Jun 15, 2017

What this PR does / why we need it:
We should use object instead of pointer for String().

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #47571

Release note:

Fix VolumeClaims/capacity in "kubectl describe statefulsets" output.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 15, 2017
@k82cn
Copy link
Member Author

k82cn commented Jun 15, 2017

The output of kubectl:

Volume Claims:
  Name:		www
  StorageClass:	anything
  Labels:	<none>
  Annotations:	volume.beta.kubernetes.io/storage-class=anything
  Capacity:	1Gi
  Access Modes:	[ReadWriteOnce]

@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jun 15, 2017
@k82cn k82cn changed the title Fixed String() of Quantity. Fixed PVC's capacity in description. Jun 15, 2017
@k82cn
Copy link
Member Author

k82cn commented Jun 15, 2017

/unassign
/assign @pwittrock @adohe

@k82cn
Copy link
Member Author

k82cn commented Jun 15, 2017

/unassign @derekwaynecarr @wojtek-t

@k82cn
Copy link
Member Author

k82cn commented Jun 15, 2017

xref kubernetes/kubectl#33

@@ -1382,7 +1382,7 @@ func describeVolumeClaimTemplates(templates []api.PersistentVolumeClaim, w Prefi
printLabelsMultilineWithIndent(w, " ", "Labels", "\t", pvc.Labels, sets.NewString())
printLabelsMultilineWithIndent(w, " ", "Annotations", "\t", pvc.Annotations, sets.NewString())
if capacity, ok := pvc.Spec.Resources.Requests[api.ResourceStorage]; ok {
w.Write(LEVEL_1, "Capacity:\t%s\n", capacity)
w.Write(LEVEL_1, "Capacity:\t%s\n", capacity.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a better way is to change %s to %v.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%v will not work :(. Here's the output of %v:

  Capacity:	{{1073741824 0} {<nil>} 1Gi BinarySI}

When we print an object by %s in go, it'll call object's String(); but Quantity.String() is using pointer (for caching string), we have to call it explicitly.

Should be func (q Quantity) String() string not func (q *Quantity) String() string at https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go#L608 .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. probably worth fix the stringer interface thing. it just looks strange to explicitly call x.String()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. According to the comments, it use (q *Quantity) String() for caching string, not sure the performance impact (e.g. build string every time); prefer to open an issue to trace it :).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#47585 to trace the discussion.

@k82cn k82cn changed the title Fixed PVC's capacity in description. Fixed statefulset PVC's capacity in kubectl description. Jun 15, 2017
@pwittrock
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 15, 2017
@pwittrock
Copy link
Member

/approve

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: k82cn, pwittrock

Associated issue: 47571

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 15, 2017
@k82cn
Copy link
Member Author

k82cn commented Jun 16, 2017

@pwittrock , should we include this in 1.7?

@saad-ali
Copy link
Member

I verified this is broken on head. Fix is very low risk. Worth picking up for 1.7. See comment #47571 (comment)

CC @dchen1107 @pwittrock

@saad-ali saad-ali modified the milestone: v1.7 Jun 20, 2017
@saad-ali
Copy link
Member

Will let @pwittrock add 1.7 milestone

@pwittrock pwittrock added this to the v1.7 milestone Jun 20, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 45268, 47573, 47632, 47818)

@k8s-github-robot k8s-github-robot merged commit 7f7c29a into kubernetes:master Jun 21, 2017
@k82cn k82cn deleted the k8s_47571 branch June 21, 2017 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubectl did not print readable message of statefulset PVC's capacity.
9 participants